﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyDoanVien.Bussiness;
using QuanLyDoanVien.Controller;
using Microsoft.Reporting.WinForms;

namespace QuanLyDoanVien.Report
{
    public partial class frmXuatLop : Form
    {
        public frmXuatLop()
        {
            InitializeComponent();
        }
        List<LopInfo> ds_lop = new List<LopInfo>();
        DataTable ds_hocsinh = new DataTable();
        LopCtrl m_LopCtrl = new LopCtrl();
        HocSinhCtrl m_HocSinhCtrl = new HocSinhCtrl();
        private void loadDSLop()
        {
            ds_lop = m_LopCtrl.Lay_DSLop();
            cmbLop.DataSource = ds_lop;
            cmbLop.ValueMember = "MaLop";
            cmbLop.DisplayMember = "TenLop";
        }

        private void LoadDSHocSinh()
        {
            if (cmbLop.SelectedIndex >=0)
            {
                List<ReportParameter> param = new List<ReportParameter>();

                LopInfo l = (LopInfo)cmbLop.SelectedItem;
                string maLop = cmbLop.SelectedValue.ToString(); 
                param.Add(new ReportParameter("lop",l.TenLop));
                ds_hocsinh = m_HocSinhCtrl.layHocSinhTheoLop1(maLop);
                try
                {
                    this.reportViewer1.LocalReport.SetParameters(param);
                }
                catch { }
                this.quanLyDoanVienDataSetBindingSource.DataSource = ds_hocsinh;
               
                this.reportViewer1.RefreshReport();

            }
        }
        private void frmXuatLop_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'quanLyDoanVienDataSet.XuatHocSinh' table. You can move, or remove it, as needed.
            // TODO: This line of code loads data into the 'quanLyDoanVienDataSet.XuatHocSinh' table. You can move, or remove it, as needed.
            // TODO: This line of code loads data into the 'quanLyDoanVienDataSet.XuatHocSinh' table. You can move, or remove it, as needed.
           // this.xuatHocSinhTableAdapter.Fill(this.quanLyDoanVienDataSet.XuatHocSinh);
            // TODO: This line of code loads data into the 'quanLyDoanVienDataSet.XuatHocSinh' table. You can move, or remove it, as needed.
          //  this.xuatHocSinhTableAdapter.Fill(this.quanLyDoanVienDataSet.XuatHocSinh);

            loadDSLop();
            
            LoadDSHocSinh();
          
        }

        private void btnTruyXuat_Click(object sender, EventArgs e)
        {
            LoadDSHocSinh();
        }
    }
}
